﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Net;
using System.Windows.Threading;
using System.IO;
using DACU.Tools;

namespace DACU
{
	/// <summary>
	/// Логика взаимодействия для App.xaml
	/// </summary>
	public partial class App : Application
	{
		public App()
		{
			ServicePointManager.UseNagleAlgorithm = true;
			ServicePointManager.Expect100Continue = true;
			ServicePointManager.CheckCertificateRevocationList = true;
			ServicePointManager.DefaultConnectionLimit = 10;
		}

		protected override void OnStartup(StartupEventArgs e)
		{
			// define application exception handler
			Application.Current.DispatcherUnhandledException += AppDispatcherUnhandledException;

			// defer other startup processing to base class
			base.OnStartup(e);
		}

		static void AppDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
		{
			//do whatever you need to do with the exception
			//e.Exception
			MessageBox.Show(e.Exception.ToString());
			try
			{
				File.AppendAllText("exception.log", "{0}: {1}\n\n-------------\n".FormatStr(DateTime.Now, e.Exception));
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.ToString());
			}
			e.Handled = true;
		}
	}
}
